package tencent;

import java.util.Scanner;

public class Main1 {
    public static boolean isPhone(int n, String s){
        int i = s.indexOf('8');
        if (-1 == i) return false;
        if(n-i<11) return false;
        return true;

    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int nextInt = sc.nextInt();
        boolean[] res = new boolean[nextInt];
        for (int i=0;i<nextInt;i++){
            int num = sc.nextInt();
            String next = sc.next();
            res[i] = isPhone(num,next);
        }
        for (int j=0;j<nextInt;j++){
            if(res[j]){
                System.out.print("YES");
            }else{
                System.out.print("NO");
            }
            if (j+1!=nextInt){
                System.out.print("\n");
            }
        }
    }
}
